<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      border: 1px red solid;
    }

    .x {
      background-color: greenyellow;
    }

    .e {
      background-color: red;
    }
  </style>
</head>

<body>
  <div id="div1" class="e">测试文本</div>
  <button onclick="a();">方法一</button>
  <button onclick="b();">方法二</button>
  <button onclick="c(); ">方法三</button>

  <script>
    function a() {
      document.getElementById("div1").style.height = "100px";
      document.getElementById("div1").style.backgroundColor = "grey";
    }
    function b() {
      document.getElementById("div1").style.height = "200px";
    }
    function c() {
      document.getElementById("div1").className = "x";
    }
  </script>
</body>

</html>